package com.demo.homework;

import java.util.Random;

/**
 * @ClassName SuperWorker
 * @Description TODO
 * @Author tianqinglong
 * @Date 17:54 2022/7/5
 * @Version 1.0
 **/
public class SuperWorker extends Worker{
    private float bonus;

    public float getBonus() {
        return bonus;
    }

    public void setBonus(float bonus) {
        if(bonus>0&&bonus<1){
            this.bonus = bonus;
        }
    }

    public SuperWorker(String name, String job, int salary, float bonus) {
        super(name, job, salary);
        this.bonus = bonus;
    }

    @Override
    public int doJob(int months) {
       int BossSalary= (int)(months*this.getSalary()*(1+this.bonus));
        System.out.println(this.getName()+"工作了"+months+"月的工资是:"+BossSalary);
        return BossSalary;
    }

    public int doJob(int months,int addtionalHours){
       int BossSalarySum=  (int)(months*this.getSalary()*(1+this.bonus)) + (int)(this.bonus*this.getSalary()*addtionalHours/100);
        System.out.println("加班100小时"+this.getName()+"工作了"+months+"月的工资是:"+BossSalarySum);
       return BossSalarySum;
    }
}
class Test{
    public static void main(String[] args) {
//        Random a = new Random();
//        float bonus = a.nextFloat();
        SuperWorker superWorker = new SuperWorker("李四","董事长",10000,0.3f);
        superWorker.doJob(10);
        superWorker.doJob(10,100);
    }
}